package com.wo.cloud.admin.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wo.cloud.admin.dto.SysUserDto;
import com.wo.cloud.admin.entity.SysUser;
import com.wo.cloud.admin.mapper.SysUserMapper;
import com.wo.cloud.admin.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2021/5/15 22:45
 * Description:
 */

@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {


    @Autowired
    private SysUserMapper userMapper;

    @Override
    public SysUser getUserByUsername(String username) {
        return userMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(StrUtil.isNotBlank(username), SysUser::getUsername, username));
    }

    @Override
    public SysUser getUserByToken() {
//        String userName = AuthenticationUtil.getUserName();
//        return userMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(StrUtil.isNotBlank(userName), SysUser::getUsername, userName));
        return null;
    }

    @Override
    public SysUserDto getRoleByToken() {
//        String userName = AuthenticationUtil.getUserName();
//        return userMapper.getRoleByUsername(userName);
        return null;
    }
}
